package com.EpidemicPrevention.service;


import com.EpidemicPrevention.mapper.LoginMapper;

import com.EpidemicPrevention.pojo.Login;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;


@Service
public  class LoginServiceImpl implements LoginService{

    @Autowired
    private LoginMapper loginMapper;
    //登录
    @Override
    public JSON Login(Login login, HttpSession session) {
        JSONObject json = new JSONObject();
        Login login1 = loginMapper.login(login);
        if (login1 != null ){
            login.setPassword("");
            json.put("msg","登录成功");
            json.put("data",login1);
            json.put("code",1);
            session.setAttribute("login_session",login1);
        }
        else {
            json.put("msg","登录失败");
            json.put("data",null);
            json.put("code",0);
        }

        return json;
    }
}
